package com.hunray.rent.service.imp;

import java.util.List;

import javax.transaction.Transactional;

import com.hunray.rent.dao.IBaseDao;
import com.hunray.rent.service.IBaseService;

@Transactional
public class BaseService<T> implements IBaseService<T> {

	@SuppressWarnings("rawtypes")
	private IBaseDao dao;

	@SuppressWarnings("rawtypes")
	public void setDao(IBaseDao dao) {
		this.dao = dao;
	}

	@SuppressWarnings("unchecked")
	@Override
	@Transactional
	public T saveOrUpdate(T t) {
		dao.save(t);
		return t;
	}

	@SuppressWarnings("unchecked")
	@Override
	public T findOne(Integer id) {
		return (T) dao.findOne(id);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<T> findAll() {
		return dao.findAll();
	}

	@SuppressWarnings("unchecked")
	@Override
	@Transactional
	public void delete(Integer id) {
		dao.delete(id);
	}

}
